package cn.ctvonline.android.kaopu.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.ctvonline.android.kaopu.R;
import cn.ctvonline.android.kaopu.activity.demo.ActivityPullRefershDemo;
import cn.ctvonline.android.kaopu.base.BaseFragment;
import cn.ctvonline.android.kaopu.widget.FloatingManager;

/**
 * Created by dujian on 15/12/2.
 */
public class DiscoverFragment extends BaseFragment {
    static final String TAG = DiscoverFragment.class + "";
    private View contentView;
    FloatingManager floatManager;
    @Bind(R.id.open_refersh_tv)
    TextView refershTv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        contentView = LayoutInflater.from(activity).inflate(R.layout.fragment_discover, container, false);
        initViews();
        return contentView;
    }

    private void initViews() {
        ButterKnife.bind(this, contentView);
        floatManager = new FloatingManager(activity);
        floatManager.createFloatView(16);
        refershTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                floatManager.hideFloatView();
                Intent intent = new Intent(activity, ActivityPullRefershDemo.class);
                activity.startActivity(intent);
            }
        });
    }

    @Override
    public void onVisiable() {
        if (floatManager != null) {
            floatManager.showFloatView();
        }
    }

    @Override
    public void onInVisiable() {
        if (floatManager != null) {
            floatManager.hideFloatView();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
